package com.api.test;

import java.security.*;

import cn.com.jit.csp.cypher.cipher.CertAuthClient;
import cn.com.jit.csp.cypher.result.AuthSignResult;
import cn.com.jit.csp.cypher.utils.KeyUtil;

public class WuTest2_MMPT {
	public static void main(String[] args) {
		//初始流程：创建非对称密钥
		KeyPair sm2KeyPair;
		try {
			sm2KeyPair = KeyUtil.generateSM2KeyPair();
			String sm2PublicKeyBase64= KeyUtil.getSM2PublicKeyBase64(sm2KeyPair);
			String sm2PrivateKeyBase64= KeyUtil.getSM2PrivateKeyBase64(sm2KeyPair);
			System.out.println("公钥     "+sm2PublicKeyBase64);
			System.out.println("私钥     "+sm2PrivateKeyBase64);
			//应用身份认认，授权码签名
			//参数私钥的base64值， 公钥给密码平台
			PrivateKey sm2PrivateKey= KeyUtil.SM2KeyBase64ConvertPirvateKey("MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgt4Tmuz+2RYC1fkrnOenTszOxCp0Wh5BmppeTzDaGCfCgCgYIKoEcz1UBgi2hRANCAAQFm7MgGLqcJ2PT7KXvdOTbaVyNh9ylIU403OJYdEHldseL9kuDk0gph+V9KnZWC3LfCAGz0JY7QqLY8neWH7Hs");
			//autCode授权码
			AuthSignResult sm2AuthSignResult2= (AuthSignResult) CertAuthClient.keyAuthCodeSign(sm2PrivateKey,"OWJmZWU5ZTYyZjdmNGZiMmIwMGVhYzJlYmMwYzRlZmQ=");
			System.out.println("签名值    "+sm2AuthSignResult2.getSignature());
			System.out.println("签名算法    "+sm2AuthSignResult2.getSignAlgorithm());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		

	}

}


